//
//  UFOSXPMusicPlayer.m
//  unrivalledForUniverse
//
//  Created by dllo on 16/1/20.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "UFOSXPMusicPlayer.h"
#import "STKAudioPlayer.h"
@interface UFOSXPMusicPlayer ()
@property (nonatomic, retain) STKAudioPlayer *STKPlayer;
@end
@implementation UFOSXPMusicPlayer

- (void)dealloc
{
    [_STKPlayer release];
    [super dealloc];
}

// 创建单例
+ (instancetype)sharePlayer
{
    static UFOSXPMusicPlayer *musicPlayer = nil;
    
    if (nil == musicPlayer) {
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            musicPlayer = [[UFOSXPMusicPlayer alloc] init];
            [musicPlayer createPlayer];
        });
    }
    return musicPlayer;
}

// 创建播放器
- (void)createPlayer
{
    STKAudioPlayerOptions playerOptions = {YES, YES, {50, 100, 200, 400, 800, 1600, 2600, 16000}};
    
    self.STKPlayer = [[[STKAudioPlayer alloc] initWithOptions:playerOptions] autorelease];
//    self.STKPlayer.volume = 0.5;
}

// 播放远程url
- (void)playWithUrlStr:(NSString *)urlStr
{
    NSURL *url = [NSURL URLWithString:urlStr];
    STKDataSource* dataSource = [STKAudioPlayer dataSourceFromURL:url];
    [self.STKPlayer playDataSource:dataSource];
}



@end
